<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta charset='utf-8'>
        <meta name="author" content="order by dede58.com"/>
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<title>游戏详情</title>
		<meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta http-equiv="Cache-Control" content="no-siteapp">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<meta name="keywords" content="">
		<meta name="description" content="">
		<link rel="stylesheet" type="text/css" href="css/page.css" />
		<link rel="stylesheet" type="text/css" href="css/base.css" />
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		
		<!-- 引入 layui.css -->
		<link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
		 
		<!-- 引入 layui.js -->
		<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
		
		
		<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="js/jquery.SuperSlide.2.1.js"></script>
		<script src="js/common.js"></script>
		
		<script src="js/head.js"></script>
		
		
		
		
		<style>
		
		</style>
		
	</head>
	
	<script>
	$(function(){
			
			
			/* 获取登录信息 */
			let nickname = "${sessionScope.customer.nickname}";
			let content = "";
			if(nickname!=""){
				content = "<span class=\"fl\">欢迎</span>"+
						"<a href=\"grxx.jsp\" class=\"fl\">"+nickname+"</a>"+
						"<span class=\"fl\">进入商城</span>"+
						"<a href=\"../LoginServlet?op=customerLogout\" class=\"fl\">退出登录</a>";
			}else{
				content = "<span class=\"fl\">您好，请</span>"+
						"<a href=\"sign.jsp\" class=\"fl\">登录</a>";
			}
			$("#customerInfo").html(content);
			
			$(document).on("click","#shopCount",function(){
				if(nickname!=""){
					$(this).prop("href","shopping.jsp");
				}else{
					alert("请先登录");
				}
			});
			
		});
			
	</script>
	
	<script type="text/javascript">
	$(function(){
		/* 通过游戏编号查询游戏信息中的图片展示在游戏详情页面上 */
		$.ajax({
			async:false,// 使用同步进行添加，异步无法添加
			type:"GET",
			url:"../GamesServlet",
			data:{
				op:"find",
				gamesId:${param.gamesId}
			},
			contentType:"application/x-www-form-urlencoded",
			dataType:"json",
			success:function(result,status,xhr){
				let i = result.data.image;
				let array = i.split(".");
				array[0] = array[0].replace("0",""); 
				$("#showbox").children().each(function(index,img){
					$(this).prop("src","/gamestore/FileDownloadServlet?type=image&fileName="+array[0]+index+"."+array[1]);
				});
			},
		});
	});
	
	
	</script>
	
	<script type="text/javascript">
		$(function(){
			/* 获取购物车中游戏数量*/
			let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
			
			function s(){
				if(id!=0){
					$.ajax({
						async:true,
						type:"GET",
						url:"../OrderServlet",
						data:{
							op:"find",
							orderNo:"0",
							customerId:id
						},
						contentType:"application/x-www-form-urlencoded",
						dataType:"json",
						success:function(result,status,xhr){
							let count = 0;
							$.each(result.data,function(index,games){
								count = index + 1;
							});
							$("#shopCount").text("购物车（"+count+"）");
							
						},
						
					});
				}
				
					
			}
			/* 调用方法获取购物车中游戏数量*/
			s();
		});
		</script>
	
	<body>
		
		<!--Main-wrap-->
		<div class="main-wrap graybgtwo pt40 pb40" id="cen" style="margin-top: 86px;">
			<div class="wrapper">
				<!--Main-pro-info-->
				<div class="main-pro-info white-box  clearfix">
					<div class="fangda clearfix fl">
						<div id="showbox">
						  <img id="img1" src="img/COD16.jpg" width="1000" height="1000" />
						  <img src="img/COD16-2.jpg" width="1000" height="1000" />
						  <img src="img/COD16.jpg" width="1000" height="1000" />
						  <img src="img/COD16-2.jpg" width="1000" height="1000" />
						  <img src="img/COD16.jpg" width="1000" height="1000" />
						  <img src="img/COD16-2.jpg" width="1000" height="1000" />
						  <img src="img/COD16.jpg" width="1000" height="1000" />
						  
						</div><!--展示图片盒子-->
						<div id="showsum"></div><!--展示图片里边-->
						<p class="showpage">
						  <a href="javascript:void(0);" id="showlast"> < </a>
						  <a href="javascript:void(0);" id="shownext"> > </a>
						</p>
						
						</div>
					<!--产品信息介绍-->
					<div class="fr pro-intro">
						<div id="productInformation">
							<!-- <div class="pb20 line-bot">
								<h3 class="fs26 darkblack lh50 ellipsis">使命召唤16现代战争2</h3>
								<p class="fs14 lh20 over2">这里是简介这个游戏的内容</p>
								<p class="price pt10 clearfix"><strong class="fl red fs40">¥1000</strong><em class="fl white ml20 lh20 mt20">已售：2000件</em></p>
							</div>
							<div class="pro-ctent clearfix">
								<ul>
									<li><span>艺 术 家 ：</span>张文标</li>
									<li><span>尺      寸 ：</span>50×50cm</li>
									<li><span>价      格 ：</span>2000-3000</li>
									<li><span>材      质 ：</span>纸本设色</li>
									<li><span>年      代 ：</span>2015年</li>
								</ul>
							</div> -->
						</div>
						
						<div class="pt10">
							<div class="but-box mt30" id="operation">
								<input type="button" id="ljgm" class="ch fl orange-but radius3" value="立即购买">
								<input type="button" id="jrgwc" class="ch fl ml20 orange-but gray-but radius3" value="加入购物车">
							</div>
						</div>
					</div>
					
					
					<script type="text/javascript">
					/* 获取游戏信息 */
					$.ajax({
						async:true,
						type:"GET",
						url:"../GamesServlet",
						data:{
							op:"find",
							gamesId:${param.gamesId}
						},
						contentType:"application/x-www-form-urlencoded",
						dataType:"json",
						success:function(result,status,xhr){
							if(result.status == 1){
								let t = result.data.onsaleTime;
								let array = t.split("T");
								let time = array[0];
								$("#productInformation").html("<div class=\"pb20 line-bot\">"+
										"<h3 class=\"fs26 darkblack lh50 ellipsis\">"+result.data.gamesName+"</h3>"+
										"<p class=\"fs14 lh20 over2\"></p>"+
										"<p class=\"price pt10 clearfix\"><strong class=\"fl red fs40\">¥"+result.data.price+"</strong><em class=\"fl white ml20 lh20 mt20\">已售：2000件</em></p>"+
									"</div>"+
									"<div class=\"pro-ctent clearfix\">"+
										"<ul>"+
											"<li><span>商      家 ：</span>"+result.data.business.nickname+"</li>"+
											"<li><span>类      型 ：</span>"+result.data.gamesType.typeName+"</li>"+
											"<li><span>参考价格 ：</span>¥"+(parseInt(result.data.price)-30)+"-"+(parseInt(result.data.price)+30)+"</li>"+
											"<li><span>上架日期 ：</span>"+time+"</li>"+
											"<li style=\"width:100%\"><span>简      介 ：</span>"+result.data.content+"</li>"+
										"</ul>"+
									"</div>");
								let content = "<span><h1>简      介 ："+result.data.content+"</h1></span>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>"+
								"<p><img id=\"\" src=\"\" alt=\"\" style=\"width:100%;\"/></p>";
								let i = result.data.image;
								let a = i.split(".");
								a[0] = a[0].replace("0",""); 
								$("#gameDetail").html(content);
								$("#gameDetail").children("p").each(function(index,p){
									$(this).children().prop("src","/gamestore/FileDownloadServlet?type=image&fileName="+a[0]+index+"."+a[1]);
								});
								
								
								
								
								
								
								
								
							}	
						},
					});
					</script>
					
					
					<script type="text/javascript">
					// 页面加载判断登录的用户是否已经购买过该游戏
					$(function(){
						let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
						if(id!=0){
							// 查询用户的【订单中】是否已经存在该游戏也即用户之前是否【已经购买过】该游戏
							$.ajax({
								async:true,
								type:"GET",
								url:"../OrderServlet",
								data:{
									op:"repeat",
									gamesId:${param.gamesId},
									status:"1",
									customerId:id
								},
								contentType:"application/x-www-form-urlencoded",
								dataType:"json",
								success:function(result,status,xhr){
									if(result.status == 1){// 若已购买则显示已购买
										$("#operation").html("<input type=\"button\" id=\"ljgm\" class=\"ch fl orange-but radius3\" value=\"已购买\" style=\"background-color:rgb(0, 128, 0)\">");
									}
									
								},
							});
						}
						
					});
					
					
					</script>
					
					
					<script type="text/javascript">
					$(function(){
						let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
					
						$("input[value='立即购买']").click(function(){
							// 点击立即购买先检查是否登录
							if(id!=0){
								// 在点击立即购买之前查询用户的【订单中】是否已经存在该游戏也即用户之前是否【已经购买过】该游戏
								$.ajax({
									async:true,
									type:"GET",
									url:"../OrderServlet",
									data:{
										op:"repeat",
										status:"1",
										gamesId:${param.gamesId},
										customerId:id
									},
									contentType:"application/x-www-form-urlencoded",
									dataType:"json",
									success:function(result,status,xhr){
										if(result.status == 0){
											window.location.href="jiesuan.jsp?gamesId=${param.gamesId}";
										}else{
											alert("您已购买过该游戏");
										}
										
									},
								});
							}else{
								alert("请先登录才能购买");
							}
						});
							
						// 在加入购物车之前查询用户的购物车中是否已存在该游戏
						$("input[value='加入购物车']").click(function(){
							if(id!=0){
								$.ajax({
									async:true,
									type:"GET",
									url:"../OrderServlet",
									data:{
										op:"find",
										orderNo:"0",
										gamesId:${param.gamesId},
										customerId:id
									},
									contentType:"application/x-www-form-urlencoded",
									dataType:"json",
									success:function(result,status,xhr){
										if(result.status == 0){
											addShop();
											window.location.href="shopping.jsp?gamesId=${param.gamesId}";
										}else{
											alert("您的购物车中已存在该游戏");
										}
										
									},
								});
							}else{
								alert("请先登录才能将游戏加入购物车");
							}
							
						});
					});
					/* 在数据库生成一条订单号为0的订单详情 */
					function addShop(){
						let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
						$.ajax({
							async:true,
							type:"GET",
							url:"../OrderServlet",
							data:{
								op:"add",
								orderNo:"0",
								gamesId:${param.gamesId},
								customerId:id
							},
							contentType:"application/x-www-form-urlencoded",
							dataType:"json",
							success:function(result,status,xhr){
								
								if(result.status == 1){
									//调用查询订单详情填充购物车
									s();
								}else{
									alert(result.message);
								}
								
							},
						});
					}
					
					</script>
					<!--/end-->
				</div>
				<!--/end-->
				<!--proscroll-->
				<div class="proscroll white-box mt20">
					<a class="prev" href="javascript:void(0)"></a>
					<div class="scrollWrap">
						<ul class="prolist clearfix">
							<li>
								<a href="#" class="db pic"><span><img src="img/rb.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">1</a>
								<strong class="full-db red"><em class="fs12">¥</em>00.00</strong>
							</li>
							<li>
								<a href="#" class="db pic"><span><img src="img/rb.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">2</a>
								<strong class="full-db red"><em class="fs12">¥</em>00.00</strong>
							</li>
							<li>
								<a href="#" class="db pic"><span><img src="img/rb.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">3</a>
								<strong class="full-db red"><em class="fs12">¥</em>00.00</strong>
							</li>
							<li>
								<a href="#" class="db pic"><span><img src="img/rb.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">4</a>
								<strong class="full-db red"><em class="fs12">¥</em>00.00</strong>
							</li>
							<li>
								<a href="#" class="db pic"><span><img src="img/rb.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">5</a>
								<strong class="full-db red"><em class="fs12">¥</em>00.00</strong>
							</li>
						</ul>

					</div>
					<a class="next" href="javascript:void(0)"></a>
				</div>
				<!--/end-->

				<div class="mt20 clearfix">
					<!-- <div class="fl pro-likes white-box">
						<div class="title"><strong class="fs16 white">大家都喜欢</strong></div>
						<ul class="likelist">
							<li>
								<a href="#" class="db pic"><span><img src="upload/2.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">墙角数枝梅</a>
								<strong class="full-db red"><em class="fs12">¥</em>65.00</strong>
							</li>
							<li>
								<a href="#" class="db pic"><span><img src="upload/2.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">墙角数枝梅</a>
								<strong class="full-db red"><em class="fs12">¥</em>65.00</strong>
							</li>
							<li>
								<a href="#" class="db pic"><span><img src="upload/2.jpg" alt=""/></span></a>
								<a href="#" class="full-db tit darkblack ellipsis">墙角数枝梅</a>
								<strong class="full-db red"><em class="fs12">¥</em>65.00</strong>
							</li>

						</ul>
					</div> -->
					
					<div class="pro-detail box-s" style="width: 1200px;"><!-- fr --> 
						<div class="tab-hd box-s">
								<ul class="tab-nav clearfix">
								  <li class="fs16 box-s">游戏详情</li>
								  <li class="fs16 box-s">游戏评论</li>
								</ul>
						</div>
						<div class="tab-bd" style="width: 1080px;">
							<div class="tab-pal" id="gameDetail">
								<!-- <p></p>
								<p><img id="" src="" alt="" style="width:100%;"/></p>
								<p><img id="" src="" alt="" style="width:100%;"/></p>
								<p><img id="" src="" alt="" style="width:100%;"/></p> -->
								
							</div>
							<div class="tab-pal">
								<div class="pro-zixun clearfix">
								<div id="discuss">
									<p class="bt">评论1</p>
									<p class="bt">评论2</p>
									<p class="bt">评论3</p>
								</div>
								<hr>
									<br/>
									<p class="bt" id="replyto">玩家评论：</p>
									<div id="byReplyId"></div>
									<!-- <a name="miao"></a> -->
									<textarea name="textarea" rows="5" cols="" placeholder="请输入要评论的内容"></textarea>
									<p class="tijiao"><a href="javascript:void(0)" class="ra3" id="publish" style="margin-left: 450px;">发表评论</a></p>
									
									<div style="width: 230px;margin-top: -38px;">
									<a href="javascript:void(0)" class="ra3" id="cancelReply" style="margin-left: 450px; position: absolute; bottom: 15px; text-decoration: underline; color: red; display:none">取消回复</a>
									我们很需要您对该游戏的宝贵评价：
										<i name="good" value="1" class="layui-icon layui-icon-face-smile" style="font-size: 30px; color: rgb(194, 194, 194);">好评</i>   
										<i name="bad" value="2" class="layui-icon layui-icon-face-cry" style="font-size: 30px; color: rgb(194, 194, 194);">差评</i>
									</div>
									
								</div>
							</div>
						</div>
					</div>

				</div>

			</div>

		</div>
		<!--/end-->
		
		<script>
		
		
		
		
		</script>
		

		<script type="text/javascript">
		function rep(){
			let nickname = ${!empty sessionScope.customer.nickname} ? "${sessionScope.customer.nickname}（我）" : "玩家" ;
			$("#replyto").html(nickname+"评论：");
			$("#replyto").css("color","blue");
		}
		rep();
		$(document).on("click","#cancelReply",function(){
			rep();
			$("#cancelReply").css("display","none");
			$("#publish").html("发表评论");
			$("#byReplyId").children().remove();
		});
		</script>
		
		
		
		<script type="text/javascript">
		$(".layui-icon-face-smile").click(function(){
			
			/* $(this).css("color","green");
			$(this).siblings().css("color","#c2c2c2"); */
			let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
			if(id!=0){
				if($(this).css("color")=="rgb(194, 194, 194)"){// 灰色
					
					$(this).css("color","rgb(0, 128, 0)");
					if($(this).next().css("color")=="rgb(255, 0, 0)"){// 红色
						
						$(this).next().css("color","#c2c2c2");
					}
				}else if($(this).css("color")=="rgb(0, 128, 0)"){// 绿色
					$(this).css("color","#c2c2c2");
				}
			}else{
				alert("请先登录进行选择");
			}
		});
		$(".layui-icon-face-cry").click(function(){
			
			/* $(this).css("color","red");
			$(this).siblings().css("color","#c2c2c2"); */
			let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
			if(id!=0){
				if($(this).css("color")=="rgb(194, 194, 194)"){// 灰色
					
					$(this).css("color","rgb(255, 0, 0)");
					
					if($(this).prev().css("color")=="rgb(0, 128, 0)"){// 绿色
						
						$(this).prev().css("color","#c2c2c2");
					}
				}else if($(this).css("color")=="rgb(255, 0, 0)"){// 红色
					$(this).css("color","#c2c2c2");
				}
			}else{
				alert("请先登录进行选择");
			}
		});
		
		</script>
		
		
		
		
		<script type="text/javascript">
		
		$(function(){
			
			function fa(){
				/* 查询评论与回复包括条数 */
				$.ajax({
					async:true,
					type:"GET",
					url:"../DiscussServlet",
					data:{
						op:"find",
						gamesId:${param.gamesId}
					},
					contentType:"application/x-www-form-urlencoded",
					dataType:"json",
					success:function(result,status,xhr){
						let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;

						let content = "";
						$.each(result.data,function(index,discuss){
							if(index==result.data.length-4){
								content += "<a id=\"target\"></a>";
							}
							content += "<span><p class=\"bt\" style=\"color:black;\"><input type=\"hidden\" name=\"discussId\" value=\""+discuss.discussId+"\"><input type=\"hidden\" name=\"nickname\" value=\""+discuss.customer.nickname+"\"><b>"+discuss.customer.nickname+"</b>&nbsp&nbsp评论：<span style=\"color:#00BFFF;text-decoration:underline;\">"+discuss.content+"</span>";
							if(discuss.comment==1){
								content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<i name=\"goodfather\" value=\"1\" class=\"layui-icon layui-icon-face-smile\" style=\"font-size: 15px; color: green;\">好评</i>";   
							}else if(discuss.comment==2){
								content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<i name=\"badfather\" value=\"2\" class=\"layui-icon layui-icon-face-cry\" style=\"font-size: 15px; color: red;\">差评</i>";
							}else{
								content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp未评价";
							}
							content += "<br/>评论时间："+discuss.discussTime;
							if(discuss.customerId==id){
								content += "&nbsp&nbsp<a id=\"deletefather\" href=\"javascript:void(0)\" style=\"color:red;\">删除";
							}else {
								content += "&nbsp&nbsp<a id=\"replyfather\" href=\"#miao\" style=\"color:blue;\">回复";
							}
							content += "</a>&nbsp&nbsp";
							if(discuss.discussList.length!=0) {
								content += "<a id=\"expand\" href=\"javascript:void(0)\" style=\"color:blue;\">展开"+discuss.discussList.length+"条回复<img id=\"down\" src=\"img/icon_jt_down.png\" style=\"display:inline;\"></a>";
							}
							content += "</p>";
							$.each(discuss.discussList,function(index,discussReply){
								content += "<p class=\"bt\" style=\"color:black;display:none\">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type=\"hidden\" name=\"discussId\" value=\""+discussReply.discussId+"\"><input type=\"hidden\" name=\"nickname\" value=\""+discussReply.replyName+"\"><b>"+discussReply.replyName+"</b>&nbsp&nbsp回复&nbsp&nbsp<b>"+discussReply.byReplyName+"</b>：<span style=\"color:#00BFFF;text-decoration:underline;\">"+discussReply.content+"</span>";
								if(discussReply.comment==1){
									content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<i name=\"goodson\" value=\"1\" class=\"layui-icon layui-icon-face-smile\" style=\"font-size: 15px; color: green;\">好评</i>";   
								}else if(discussReply.comment==2){
									content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<i name=\"badson\" value=\"2\" class=\"layui-icon layui-icon-face-cry\" style=\"font-size: 15px; color: red;\">差评</i>";
								}else{
									content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp未评价";
								}
								content += "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp回复评论时间："+discussReply.discussTime;
								if(discussReply.customerId==id){
									content += "&nbsp&nbsp<a id=\"deleteson\" href=\"javascript:void(0)\" style=\"color:red;\">删除</a></p>";
								}else {
									content += "&nbsp&nbsp<a id=\"replyson\" href=\"#miao\" style=\"color:blue;\">回复</a></p>";
								}
							});
							content += "</span>";
						});
						
						$("#discuss").html(content);
					},
					
				});
			}
			/* 调用查询评论与回复包括条数 的 方法*/
			fa();
			function del(discussIdList){
				/*删除数据库中的评论*/
				$.ajax({
					async:true,
					type:"GET",
					url:"../DiscussServlet",
					data:{
						op:"delete",
						discussIdList:discussIdList
					},
					contentType:"application/x-www-form-urlencoded",
					dataType:"json",
					success:function(result,status,xhr){
						if(result.status==1){
							/* 调用查询评论与回复包括条数 的 方法*/
							fa();
						}
					},
				
				});
			}

			/* 展开或收起评论 */
			let count = "";
			$(document).on("click","#expand",function(){
				
				if($(this).parent().siblings().css("display")=="none"){
					count = $(this).text();
					$(this).parent().siblings().css("display","block");
					$(this).html("收起<img id=\"down\" src=\"img/icon_jt_up.png\" style=\"display:inline;\">");
				
				}else{
					/* $(this).parent().siblings().css("display","none"); */
					/* 调用查询评论与回复包括条数 的 方法*/
					fa();
					/* $(this).html(count+"<img id=\"down\" src=\"img/icon_jt_down.png\" style=\"display:inline;\">"); */
				
				}
			});
			/* 有子评论删除用户自己的评论以及子评论 */
			$(document).on("click","#deletefather",function(){
				
				if(confirm("确认要删除该条评论吗？")){
					let discussIdList = "";
					let fatherDiscussId = $(this).siblings("input[name='discussId']").val();
					/* 将一级评论/父评论的编号存入 */
					discussIdList += fatherDiscussId + ",";
					$(this).parent().siblings().each(function(index,e){
						let sonDiscussId = $(this).children("input[name='discussId']").val();
						/* 将所有子评论的编号存入 */
						discussIdList += sonDiscussId + ",";
					});
					if(discussIdList.length!=0){
						/* 调用发送ajax删除数据库的方法，因为该方法若删除成功会自动调用fa()方法*/
						del(discussIdList);
						
					}
					/* $(this).parents("span").remove(); */
				}
			});
			/*无子评论时删除用户自己的单条评论*/
			$(document).on("click","#deleteson",function(){
				if(confirm("确认要删除该条评论吗？")){
					/*删除数据库中的评论*/
					let sonDiscussId = $(this).siblings("input[name='discussId']").val();
					if(sonDiscussId!=null){
						/* 调用发送ajax删除数据库的方法，因为该方法若删除成功会自动调用fa()方法*/
						del(sonDiscussId);
						
					}
					/* $(this).parent().remove(); */
				}
			});
			/* 点击父级评论回复跳转回复框并传递被回复的用户名 */
			$(document).on("click","#replyfather",function(){
				/* 回复之前先判断用户是否登录 */
				let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
				if(id!=0){
					/* $("#replyto").after("<a name=\"miao\"></a>"); */
					$("#target").prop("name","miao");
					let byReplyName = $(this).siblings("input[name='nickname']").val();
					let byReplyDiscussId = $(this).siblings("input[name='discussId']").val();
					$("#replyto").text("回复	"+byReplyName+"：");
					$("#byReplyId").html("<input type=\"hidden\" name=\"byReplyDiscussId\" value=\""+byReplyDiscussId+"\">");
					$("#replyto").css("color","blue");
					$("#publish").html("回复评论");
					$("#cancelReply").css("display","inline");
				}else{
					alert("请先登录才能进行回复");
				}
				
			});
			/* 点击子级评论回复跳转回复框并传递被回复的用户名 */
			$(document).on("click","#replyson",function(){
				let id = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
				if(id!=0){
					/* $("#replyto").after("<a name=\"miao\"></a>"); */
					$("#target").prop("name","miao");
					let byReplyName = $(this).siblings("input[name='nickname']").val();
					let byReplyDiscussId = $(this).siblings("input[name='discussId']").val();
					$("#replyto").text("回复	"+byReplyName+"：");
					$("#byReplyId").html("<input type=\"hidden\" name=\"byReplyDiscussId\" value=\""+byReplyDiscussId+"\">");
					$("#replyto").css("color","blue");
					$("#publish").html("回复评论");
					$("#cancelReply").css("display","inline");
				}else{
					alert("请先登录才能进行回复");
				}
				
			});
			
			/* 点击提交评论,此时replyId为null */
			$("#publish").click(function(){
				
				let customerId = ${!empty sessionScope.customer.customerId} ?　"${sessionScope.customer.customerId}" : 0;
				if(customerId!=0){
					let textarea = $("textarea[name='textarea']").val();
					if(textarea.replace(/ +/g,"").replace(/[\r\n]/g,"").length==0){
						alert("发表的评论内容不能为空");
					}else{
						let evaluate = null;

						if($("i[name='good']").css("color") == "rgb(0, 128, 0)"){// 绿色
							evaluate="1";
							
						}else if($("i[name='bad']").css("color") == "rgb(255, 0, 0)"){// 红色
							evaluate="2";
							
						}
						
						/*添加评论到数据库中*/
						$.ajax({
							async:true,
							type:"GET",
							url:"../DiscussServlet",
							data:{
								op:"add",
								gamesId: ${param.gamesId},
								customerId: customerId,
								content: textarea,
								comment: evaluate,
								replyId:$("#byReplyId").children().val()
							},
							contentType:"application/x-www-form-urlencoded",
							dataType:"json",
							success:function(result,status,xhr){
								if(result.status==1){
									/* 调用查询评论与回复包括条数 的 方法*/
									fa();
									alert("评论发表成功");
									$("textarea[name='textarea']").val("");
									if($("i[name='good']").css("color") == "rgb(0, 128, 0)"){// 绿色
										$("i[name='good']").css("color","#c2c2c2");
									}else if($("i[name='bad']").css("color") == "rgb(255, 0, 0)"){// 红色
										$("i[name='bad']").css("color","#c2c2c2");
									}
	
									
								}
							},
						
						});
					}
				}else{
					alert("请先登录才能发表评论");
				}
				
				
				
				
			});
			
			
			
			
			
			
			/* 当鼠标在加入购物车上方时立即购买的按钮的背景颜色变灰色 */
			$("#jrgwc").mouseenter(function(){
				  $("#ljgm").css("background-color","#a2a2a2");
				  $("#jrgwc").css("background-color","#570000");
			});
			$("#jrgwc").mouseleave(function(){
				  $("#ljgm").css("background-color","#600000");
				  $("#jrgwc").css("background-color","#a2a2a2");
			});
			$("#ljgm").mouseenter(function(){
				  $("#ljgm").css("background-color","#350000");/* #570000 */
			});
			$("#ljgm").mouseleave(function(){
				  $("#ljgm").css("background-color","#600000");
			});
			
		});
		</script>
		
		
		<!--footer star-->
		<div class="footer clearfix">
			<div class="content clearfix">
				<div class="top clearfix">
					<div class="list clearfix fl box-s">
						<div class="part icon1 box-s">
							<h3>专业</h3>
							<p>拥有资深游戏顾问和先进交易平台，安全交易，快捷支付。</p>
						</div>
					</div>
					<div class="list clearfix fl box-s">
						<div class="part icon2 box-s">
							<h3>保真</h3>
							<p>阵容强大的游戏评鉴团，确保平台上的游戏货真价实。</p>
						</div>
					</div>
					<div class="list clearfix fl box-s">
						<div class="part icon3 box-s">
							<h3>保值</h3>
							<p>为您精选具备收藏价值的游戏作品，助您的资产保值、增值。</p>
						</div>
					</div>
				</div>
				<div class="bottom clearfix">
					<div class="left clearfix fl">
						<div class="list clearfix">
							<div class="shang clearfix">
								<p>新手指南</p>
								<span></span>
							</div>							
							<div class="xia clearfix">
								<ul>
									<li><a href="scgmlc.html">购买流程</a></li>
									<li><a href="cjwt.html">常见问题</a></li>
								</ul>
							</div>
						</div>
						<div class="list clearfix">
							<div class="shang clearfix">
								<p>账户管理</p>
								<span></span>
							</div>							
							<div class="xia clearfix">
								<ul>
									<li><a href="zhcz.html">账户充值</a></li>
									<li><a href="zhtx.html">账户提现</a></li>
									<li><a href="zffs.html">支付方式</a></li>
								</ul>
							</div>
						</div>						
						<div class="list clearfix">
							<div class="shang clearfix">
								<p>服务合作</p>
								<span></span>
							</div>							
							<div class="xia clearfix">
								<ul>
									<li><a href="friend-link.html">友情链接</a></li>
									<li><a href="ysjrz.html">玩家入驻</a></li>
								</ul>
							</div>
						</div>
						<div class="list clearfix">
							<div class="shang clearfix">
								<p>关于我们</p>
								<span></span>
							</div>							
							<div class="xia clearfix">
								<ul>
									<li><a href="gsjj.html">公司简介</a></li>
									<li><a href="contact.html">联系我们</a></li>
									<li><a href="jrwm.html">加入我们</a></li>
								</ul>
							</div>
						</div>
						<div class="list clearfix">
							<div class="shang clearfix">
								<p>售后服务</p>
								<span></span>
							</div>							
							<div class="xia clearfix">
								<ul>
									<li><a href="wlsm.html">交易说明</a></li>
									<li><a href="mzsm.html">免责声明</a></li>
								</ul>
							</div>
						</div>
					</div>
					<div class="middle clearfix fl">
						<ul>
							<li><img src="upload/ewm.jpg"/></li>
							<li><img src="upload/ewm.jpg"/></li>
						</ul>
					</div>
					<div class="right clearfix fr">
						<p class="bt">免费咨询热线：</p>
						<p class="tel">400-000-0000</p>
						<p class="fu-bt">(周一到周五8:00-22:00)</p>
					</div>
				</div>
			</div>
			<div class="banquan clearfix ta-center">
				Copyright © 2021 厦门游戏商城(xiamenyouxishangcheng). All Rights Reserved. 
			</div>
		</div>
		<!--footer end-->

	</body>
	<script src="js/other.js" type="text/javascript" ></script>
	
	<script>
	$(function(){
		/* 移除首页精选的红色背景 */
		$("#homepage").removeClass("cur");
	});
	</script>
	
	
	
	
</html>